PopupController

Basic controller interface for GUIs that want to implement a popup system. This does not handle interaction handling nor rendering, that needs to be integrated into the screen being built.

There are some helper methods for rendering popups in a predicatable manner. Make sure to call both!

Author

fzzyhmstrs

Since

0.6.7, moved from PopupParentElement originally 0.2.0

See also

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class PopupEntry(val parent: PopupController, val widget: PopupWidget?, val mouseX: Double? = null, val mouseY: Double? = null)

Properties

Link copied to clipboard
abstract val child: LastSelectable?
Link copied to clipboard

Boolean prevents mouseReleased from triggering on the Popup or Widget underneath the active popup if it's closed on mouseClicked

Link copied to clipboard
abstract var lastSelected: Element?

getter and setter for the cached element.

Link copied to clipboard

A stack for holding popupwidgets while allowing for easy list iteration as needed. For rendering this stack should be traversed in reverse order, which LinkedList makes easy with descendingIterator

Functions

Link copied to clipboard
Link copied to clipboard
abstract fun blurElements()

Called by this parent element when it pushes a PopupWidget to its stack. This method should "blur" the focus of the underlying children in this parent element; using blur() from Screen, for example.

Link copied to clipboard
abstract fun initPopup(widget: PopupWidget)

called when a Popup is pushed to this element, after blurring.

Link copied to clipboard
abstract fun popLast()

Indicates that the overlay has been removed and the parent should return focus to the cached element, if any, in lastSelected

Link copied to clipboard
open fun postRender(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float)

Renders the current open popups in descending order (oldest first/the farthest back) and then pops matrices. This needs to be called with preRender or the game will crash from a non-empty matrix stack.

Link copied to clipboard
open fun preRender(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float)

Pushes the current matrix and moves the content rendering back to make room for the popups. This needs to be called with postRender or the game will crash from a non-empty matrix stack.

Link copied to clipboard
abstract fun pushLast()

Indicates to the parent element to cache it's current focused element. The current focused element should be stored in lastSelected

Link copied to clipboard
open fun resetHover(mouseX: Double, mouseY: Double)

When called the parent element should reselect a hovered element based on the supplied mouse positions, if it tracks such things

Link copied to clipboard
open fun setPopup(widget: PopupWidget?, mouseX: Double? = null, mouseY: Double? = null)

Applies a popup widget to this parent. If null is passed, removes the top (newest) popup instead

Link copied to clipboard
open fun setPopupImmediate(widget: PopupWidget?, mouseX: Double? = null, mouseY: Double? = null)

Applies a popup widget to this parent. If null is passed, removes the top (newest) popup instead

Link copied to clipboard
open fun setPopupInternal(widget: PopupWidget?, mouseX: Double? = null, mouseY: Double? = null)